// Plugin For Tabs Switcher,选项卡切换插件
// By Eachcan<eachcan@gmail.com> Taomee.Inc 2009

(function($){
    $.extend({
        tab_switcher: function(params){
            var default_params = {
                'tabs': [],
                'panels': [],
                '.tabon': 'tabon',
                '.taboff': '',
                'trigger': 'mouseover'
            };
            params = $.extend(default_params, params);

            if (!params.tabs || params.tabs.length <= 0 || !params.panels || params.panels.length <= 0) {
                return this;
            }

            $.each(params.tabs, function(i, item){
                $(item).bind(params.trigger, (function(i){
                    return function(e){
                        $(params.panels).hide();
                        $(params.panels[i]).show();
                        $(params.tabs).removeClass(params['.tabon']).addClass(params['.taboff']);
                        $(params.tabs[i]).removeClass(params['.taboff']).addClass(params['.tabon']);
                    };
                })(i));
            });
        }
    });
})(jQuery);
